package com.daihou.BCJ.sysconfig;


import com.alibaba.fastjson.JSONObject;
import com.daihou.config.TheAuth;
import com.daihou.model.ceres.SysConfigUrlEnum;
import com.daihou.utils.DHConfigFile;
import com.daihou.utils.DHHttpUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class ContactType {
    private static final Logger logger = LoggerFactory.getLogger(ContactType.class);
    private String url;
    Map<String, String> headers = new HashMap<>();

    @BeforeTest(description = "测试准备工作,获取Authorization对象")
    public void beforeTest() throws IOException {
        url = DHConfigFile.getUrl("DaiHou_URL", "systemconfig", SysConfigUrlEnum.GETCONTACTTYPE.toString());
        //设置请求头中的Authorization
        headers.put("Authorization", TheAuth.getAuth());
        headers.put("X-UserName", "admin");
    }

    @Test(description = "案件关联联系人类型查询")
    public void caseContactTypeQueryTest() {
        String result = Objects.requireNonNull(DHHttpUtil.post_with_String(url, new JSONObject().toJSONString(), headers)).toJSONString();
        logger.info("案件关联联系人类型查询结果:{}", result);
        Assert.assertTrue(result.contains("\"message\":\"操作成功\",\"status\":\"0\""));
    }
}